#define _CRT_SECURE_NO_WARNINGS 1


#include<stdio.h>
#include<string.h>


int main()
{
	int n = 0, i = 0, j = 0, k = 0, c = 0;
	double temp = 0, a[100] = { 0 }, b[100] = { 0 };
	char arr[100] = { 0 };
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%s %lf", arr, &temp);
		if (strcmp(arr, "male") == 0)
			a[j++] = temp;
		else if (strcmp(arr, "female") == 0)
			b[k++] = temp;
	}
	for (i = 0; i < j; i++)
	{
		for (c = i + 1; c < j; c++)
		{
			if (a[i] > a[c])
			{
				temp = a[i];
				a[i] = a[c];
				a[c] = temp;
			}
		}
	}
	for (i = 0; i < k; i++)
	{
		for (c = i + 1; c < k; c++)
		{
			if (b[i] < b[c])
			{
				temp = b[i];
				b[i] = b[c];
				b[c] = temp;
			}
		}
	}
	for (i = 0; i < j; i++)
		printf("%.2lf ", a[i]);
	for (i = 0; i < k; i++)
		printf("%.2lf ", b[i]);

	return 0;
}	